﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ITOMMS.Entity;
using ITOMMS.Business;
using Watson.Core.Tools;

namespace ITOMMS.Web.Notice
{
    public partial class NoticeAdd : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                tbNoticeEntity entity = new tbNoticeEntity();
                if (ViewState["Entity"] != null)
                {
                    entity = ViewState["Entity"] as tbNoticeEntity;
                }
                else
                {
                    entity.CreateBy = SessionHelper.UserID;
                    entity.CreateDate = DateTime.Now;
                }
                entity.Title = txtTitle.Text.Trim();
                entity.Content = FreeTextBox1.Text;
                entity.Type = int.Parse(this.ddlType.SelectedValue.Trim());
                entity.ModifyBy = SessionHelper.UserID;
                entity.ModifyDate = DateTime.Now;
                entity.SaveOrUpdate();

                ViewState["Entity"] = entity;
              
                MessageboxInfo.MessageBox(this, MessageType.SUCCEEDED, "保存成功");
            }
            catch (Exception ex)
            {
                log4netHelper.error(ex);
                MessageboxInfo.MessageBox(this, MessageType.ERROR, "保存失败");
            }
        }
    }
}
